﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using MyDMS.DAL;

public partial class Compose : PageBaseClass
{
    MyDMSEntity myDmsEntity=new MyDMSEntity();

    protected void Page_Load(object sender, EventArgs e)
    {
        txtSentDate.Text = DateTime.Now.ToString("MMM d, yyyy");
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        MailMessage mMsg = new MailMessage();
        mMsg.Message_Subject = txtDocName.Text;
        mMsg.Message_Body = txtBody.Text;
        mMsg.Sent_Date = DateTime.Parse(txtSentDate.Text);

        mMsg.Owner = Author.user_Code;
        mMsg.Office_Code = Author.office_Code;
        mMsg.Creation_Date = DateTime.Now;
        mMsg.Updation_Date = DateTime.Now;

        myDmsEntity.AddToMailMessage(mMsg);
        if(myDmsEntity.SaveChanges()>0)
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Failed";
        }
        lblMessage.Visible = true;
    }
}
